package main

import (
	basewsclient "gitee.com/851537/gpkg/wsclient/base"
	"gitee.com/851537/gpkg/wsclient/example"
	"github.com/cloudwego/hertz/pkg/common/hlog"
)

func main() {
	client := example.NewClient(
		basewsclient.WithDebug(true),
		//basewsclient.WithUrl("wss://stream.binance.com:443/stream?streams=btcusdt@depth5@1000ms"),
		basewsclient.WithUrl("wss://wseea.okx.com:8443/ws/v5/public"),
		basewsclient.WithOnConnected(func(child basewsclient.IWsClient) {
			hlog.Debugf("已连接")
		}),
		basewsclient.WithOnDisconnect(func(child basewsclient.IWsClient) {
			hlog.Debugf("已断开")
		}),
		basewsclient.WithOnMessage(func(child basewsclient.IWsClient, msg []byte, msgType ...int) {
			hlog.Debugf("收到消息 %s", string(msg))
		}),
		basewsclient.WithPingHandler(func(appData string) error {
			hlog.Debug("收到ping数据", appData)
			return nil
		}),
		basewsclient.WithPongHandler(func(appData string) error {
			hlog.Debug("收到pong数据", appData)
			return nil
		}),
		basewsclient.WithPingType(basewsclient.PingTypeText),
		basewsclient.WithPingContent("ping"),
		basewsclient.WithPingInterval(5),
	)
	// go func() {
	// 	for {
	// 		time.Sleep(3 * time.Second)
	// 		client.CheckConn()
	// 		//client.Close()
	// 		//client.Conn.Close()
	// 	}
	// }()

	client.Start()
}
